import { randomTxtLibrary } from "../../../utils";
import { host } from "../../global.config";
import { AddTemplateConfigEntity } from "../../test.entity";
import { LibrariesItemConfig } from "./index.config";

const name = `自动化测试库-新建计划${randomTxtLibrary('number', 1)}`;
export const TesthubLibrariesPlansConfig: AddTemplateConfigEntity = {
  title: 'Testhub模块添加测试库用例计划',
  pageUrl: `${host.url}/testhub/libraries`,
  dialogTitle: '新建测试计划',
  screenshotName: 'testhub_add_plans_tests',
  btnGroup: [
    {
      type: 'click',
      name: 'nav',
      selector: '.nav-link span:has-text("试计")',
      delay: 2000,
    }
  ],
  operation: {
    type: 'click',
    name: 'addLibrariesBut',
    selector: 'a:has-text("新建计划")',
  },
  from: [
    {
      type: 'fill',
      name: 'name',
      selector: 'input[name="name"]',
      label: '计划名称',
      value: name,
      err_msg: ['计划名称不能为空'],
    },
    {
      type: 'select',
      name: 'library',
      label: '所属测试库',
      selector: '.thy-select[name="library"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item span',
      value: [LibrariesItemConfig.name]
    },
    {
      type: 'select',
      name: 'selectMember',
      label: '负责人',
      selector: '.thy-select[name="selectMember"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item div',
      value: ['wang'],
      err_msg: ['负责人不能为空'],
    },
    {
      type: 'picke',
      name: 'start',
      selector: '.thy-calendar-picker[name="start"]',
      label: '开始时间',
      value: '2021-8-15 13:59',
      boxSelector: '.thy-calendar-picker-container',
    },
    {
      type: 'picke',
      name: 'due',
      selector: '.thy-calendar-picker[name="due"]',
      label: '结束时间',
      value: '2021-8-16 13:59',
      boxSelector: '.thy-calendar-picker-container',
    },
    {
      type: 'click',
      name: 'okBtn',
      selector: 'button:has-text("确定")',
    },
  ],
  testPage: {
    table: {
      selector: 'table',
      result: [
        {label: '计划名称', value: name},
        {label: '负责人', value: 'wang'},
        {label: '开始时间', value: '8月15日'},
        {label: '结束时间', value: '8月16日'}
      ],
    },
  },
};
